import org.junit.jupiter.api.Test;

/**
 * @author chenzy
 * @since 2024-05-18
 **/
public class 虚拟线程学习 {
    @Test
    void 创建虚拟线程1() {
        var begin=System.currentTimeMillis();

        var ofVirtual=Thread.ofVirtual().name("国家",1);
        var thread1=ofVirtual.start(()->{
            System.out.println(Thread.currentThread().getName()+":"+123);
        });
        var thread2=ofVirtual.start(()->{
            System.out.println(Thread.currentThread().getName()+":"+123);
        });
        System.out.println(thread1.getName());
        System.out.println(thread2.getName());
//        ofVirtual.run();
        System.out.println("耗時"+(System.currentTimeMillis()-begin));
    }
}
